<?php
declare (strict_types = 1);

namespace app\home\controller;

use app\base\BaseController;
use think\facade\Db;
use think\facade\View;

class Sl extends BaseController
{

    public function index()
    {
        if (request()->isAjax()) {
            $param = get_params();
            $map = [];
            if($param['send']==1){
                if (!empty($param['type'])) {
                    $map[] = ['type', '=', $param['type']];
                }
                //按时间检索
                if (!empty($param['diff_time'])) {
                    $diff_time =explode('~', $param['diff_time']);
                    $map[] = ['create_time', 'between', [strtotime(urldecode($diff_time[0])),strtotime(urldecode($diff_time[1]))]];
                }
                $map[] = ['admin_id', '=', $this->uid];
                $map[] = ['status', '=', 1];
                $list = $this->getSend($map, $param);
            }
            else{
                if (!empty($param['read'])) {
                    if($param['read']==1){
                        $map[] = ['a.read_time', '=', 0];
                    }else{
                        $map[] = ['a.read_time', '>', 0];
                    }
                }
                if (!empty($param['type'])) {
                    $map[] = ['w.type', '=', $param['type']];
                }
                $map[] = ['a.to_uid', '=', $this->uid];
                $map[] = ['a.status', '=', 1];
                //按时间检索
                if (!empty($param['diff_time1'])) {
                    $diff_time =explode('~', $param['diff_time1']);
                    $map[] = ['send_time', 'between', [strtotime(urldecode($diff_time[0])),strtotime(urldecode($diff_time[1]))]];
                }
                $list = $this->getList($map, $param);
            }
            return table_assign(0, '', $list);
        } else {
            return view();
        }
    }

    public function index2()
    {
        return view();

    }
    public function index3()
    {
        return view();

    }
    public function index4()
    {
        return view();

    }



}
